<?php
namespace app\index\controller;

use app\index\model\Label as LabelModel;

class Label
{
    public function index($articleId=0){
        $where = $whereAssoc = [];
        //判断
        if ($articleId){
            $whereAssoc['article'] = ['id', '=', $articleId];
        }
        //获取列表
        $label = new LabelModel();
        $list = $label->getDetail($where, $whereAssoc);
        $list->load('article'); // 延迟预载入

        return json($list);
    }

    public function read($id){
        //获取详情
        $article = new ArticleModel();
        $detail = $article->getDetailById($id);

        return $detail;
    }

}